//从插件内导出createRouter、createWebHashHistory
import { createRouter , createWebHashHistory } from "vue-router";


import LoginCom from "@/components/LoginCom.vue";
import HomeCom from "@/components/HomeCom.vue";
import UserLogin from "@/components/UserLogin.vue"
    import ProductList from "@/components/childperson/ProductList.vue";
    import AddPerson from "@/components/childperson/AddPerson.vue";
    import ListPerson from "@/components/childperson/ListPerson.vue";
    import SchoolList from "@/components/childperson/SchoolList.vue";
    import EditPerson from "@/components/childperson/EditPerson.vue";
    import EditProd from "@/components/childperson/EditProd.vue";
    //定义路由表
const routes=[
    {
        path:'/',//刚启动浏览器的时候
        redirect : '/editprod',//当启动浏览器时，将地址强制跳转到LoginCom页面  
    },
    {
        path : '/login',
        name : "LoginCom",
        component : LoginCom
    },
    {
        path : '/home',
        name : "HomeCom",
        component : HomeCom,
        children:[{
            path : '/add',
            name : "AddPerson",
            component : AddPerson,
        },
        {
            path : '/list',
            name : 'ListPerson',
            component : ListPerson,
        },
        {
            path : '/school',
            name : 'SchoolList',
            component : SchoolList,
        },
        {
            path : '/editperson',
            name : 'EditPerson',
            component : EditPerson,
        },  
        {
        path : '/productlist',
        name : "ProductList",
        component : ProductList
        }, 
        {
            path : '/editprod',
            name : "EditProd",
            component : EditProd
            }, 
        ]
    },
    {
        path : '/userlogin',
        name : "UserLogin",
        component : UserLogin
    },
    
];

//定义路由器/创建路由器
const router = createRouter({
    //调用路由表、实现router-link的跳转以及router-view的渲染
    //routes : routes,
    routes,
    //将路由的历史模式设置为Hash模式
    history : createWebHashHistory(),
});

// 导出路由器
export default router;